package cn.topevery.garden.dal.dao.impl;

import cn.topevery.garden.dal.dao.MessageDao;
import cn.topevery.garden.entity.po.Message;
import cn.topevery.garden.entity.query.MessageQuery;
import cn.topevery.garden.entity.vo.MessageVO;
import cn.topevery.garden.framework.base.BaseDaoImpl;
import hw.topevery.framework.db.entity.DataPager;
import hw.topevery.framework.db.entity.SqlQueryMate;
import hw.topevery.framework.db.enums.ScriptConditionEnum;
import hw.topevery.framework.entity.DbCsp;
import hw.topevery.framework.entity.KeyValue;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 留言表
 *
 * @author code-generate
 * @date 2022-02-18
 */
@Repository
public class MessageDaoImpl extends BaseDaoImpl<Message> implements MessageDao {
    @Override
    public <P extends DbCsp> List<Message> getSearch(P para) {
        return null;
    }

    

    @Override
    public DataPager<MessageVO> listPage(MessageQuery query) {
        String table = "t_message tm";

        String columns = "tm.*";

        int pageIndex = query.pageIndex - 1;
        int pageSize = query.pageSize;

        SqlQueryMate sqlQueryMate = new SqlQueryMate(table).setColumns(columns).setOrderBy("tm.c_id desc");
        sqlQueryMate
                .where(true, "tm.c_db_status", ScriptConditionEnum.Eq, 0)
        ;

        return getDataPager(sqlQueryMate, pageSize, pageIndex, MessageVO.class);
    }

    @Override
    public Message getEntityByColumn(String key,String value){
        KeyValue<String> map=new KeyValue<>();
        map.key=key;
        map.value=value;
        return getEntityByColumnEqValue(map);
    }
}
